/************************************************************************
* Model class, describe data content, including mapping, next items, 
* color, etc ...
* Author : Shaolan
* Version : 1.0
* Website : http://shaolan.net
*/
#include <string>
#include <list>

#ifndef LIBGE_HEADER
	#include <libge/libge.h>
	#define LIBGE_HEADER 1
#endif

#define NEXT 10

enum Item { EMPTY, RED , BLUE , GREEN };
		
struct Block {
	int x,y,speed,start;
	Item data[4];
	Block();
	Block(int,int,Item[4]);
};


class Model {
	public:
		// Constructor
		Model();
		Model(int,int);
		// Destructor
		~Model();
		// Getters
		int getWidth() const;
		int getHeight() const;
		double getScore() const;
		Item getMapping(int,int) const;
		std::list<Block> * getNext();
		std::list<Block> * getFalling();
		// Setters
		void setWidth(int);
		void setHeight(int);
		void setScore(double);
		void setMapping(int,int,Item);
		// Common method	
		Block makeRandomBlock(); 
		void fillNext();
		void popNextItem(); 
		void pushFallingItem(Block); // Ajoute un block en chute
		void connect(Block); // Connecte un block en chute a la grille
		void updateMapping(); // Verifie la presence de block uniforme et met a jour leur statuts
	protected:
		double score;
		std::list<Block> next;
		std::list<Block> falling;
		Item ** mapping;
		int width, height;
};